﻿using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Media;
using SomeGame.Actors.Components;
using SomeGame.Actors.Components.State;
using SomeGame.GUI;
using SomeGame.Zones;
using FacingDirection = SomeGame.Actors.Components.FacingDirection;

namespace SomeGame.Input {

    public static class InputActions {

        public static void Exit() {
            if (ScreenManager.ScreenIsActive(ScreenManager.PLAY_SCREEN) && !GameEngine.IsPaused) {
                ScreenManager.ActivateScreen(ScreenManager.PAUSED_SCREEN);
                GameEngine.IsPaused = true;
                return;
            }
            if (ScreenManager.ScreenIsActive(ScreenManager.ARE_YOU_SURE_SCREEN)) {
                GameEngine.ExitGame();
                return;
            }
            if (ScreenManager.ScreenIsActive(ScreenManager.PAUSED_SCREEN)) {
                ScreenManager.DeactivateScreen(ScreenManager.PAUSED_SCREEN);
                GameEngine.IsPaused = false;
                return;
            }
            MediaPlayer.Stop();
            ZoneManager.UnloadZone();
            GameEngine.ExitGame();
        }

        public static void PlayerWalkLeft() {
            GameEngine.Player.State.SetCurrentState(PlayerStateMachine.State.WalkingLeft);
        }

        public static void PlayerWalkRight() {
            GameEngine.Player.State.SetCurrentState(PlayerStateMachine.State.WalkingRight);
        }

        public static void PlayerStopWalking() {
            GameEngine.Player.State.SetCurrentState(PlayerStateMachine.State.Idle);
        }

        public static void PlayerAttack() {
            GameEngine.Player.State.SetCurrentState(PlayerStateMachine.State.Attacking);
        }

        public static void PlayerStopAttack() {
            GameEngine.Player.State.SetCurrentState(PlayerStateMachine.State.WaitingForAttackToComplete);
        }

        public static void ToggleFullScreen() {
            GameEngine.GraphicsDeviceManager.ToggleFullScreen();
        }

    }

}